package com.chrray.position.controller.app;

import com.baomidou.mybatisplus.extension.api.R;
import com.chrray.position.domain.dto.*;
import com.chrray.position.domain.vo.FdAuthEnterpriseVO;
import com.chrray.position.domain.vo.FdAuthPersonalVO;
import com.chrray.position.domain.vo.FdUserResumeVO;
import com.chrray.position.service.position.FdUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 业务系统用户控制器
 *
 * @author wusiwee
 * @email wusiwee@163.com
 * @since 1.0.1 2024-08-07
 */
@RestController
@RequestMapping("/api/app/user")
@Api(tags = "业务系统用户")
@AllArgsConstructor
public class FdUserController {

    private final FdUserService fdUserService;

    @PostMapping("/location")
    @ApiOperation("更新当前用户最新坐标")
    public R<String> updateLocation(@RequestBody LocationDTO location) {
        fdUserService.updateLocation(location);
        return R.ok("操作成功");
    }

    // 查看个人认证信息
    @GetMapping("/personal-auth-info")
    @ApiOperation("查看个人认证信息")
    public R<FdAuthPersonalVO> getPersonalAuthInfo(@RequestParam(value = "userId",required = false) Long userId){
        return R.ok(fdUserService.getPersonalAuthInfo(userId));
    }

    // 查看企业认证信息
    @GetMapping("/ent-auth-info")
    @ApiOperation("查看企业认证信息")
    public R<FdAuthEnterpriseVO> getEnterpriseAuthInfo(@RequestParam(value = "userId",required = false) Long userId){
        return R.ok(fdUserService.getEnterpriseAuthInfo(userId));
    }

    @GetMapping("/resume")
    @ApiOperation("查看个人简历")
    public R<FdUserResumeVO> getResume(@RequestParam(value = "userId",required = false) Long userId){
        return R.ok(fdUserService.getResume(userId));
    }


    @PostMapping("/info")
    @ApiOperation("编辑个人信息")
    public R<String> updateInformation(@RequestBody @Validated FdUserInformationDTO info) {
        fdUserService.updateInformation(info);
        return R.ok("操作成功");
    }

    // 更新生活照
    @PostMapping("/life-photo")
    @ApiOperation("更新生活照")
    public R<Boolean> updateLifePhoto(@RequestBody @Validated LifePhotoDTO photo) {
        return R.ok(fdUserService.updateLifePhoto(photo));
    }

    // 更新求职意向
    @PostMapping("/intention")
    @ApiOperation("编辑求职意向")
    public R<FdJobIntentionsDTO> updateIntention(@RequestBody @Validated FdJobIntentionsDTO intention) {
        return R.ok(fdUserService.updateIntention(intention));
    }

    // 更新教育经历
    @PostMapping("/edu-exp")
    @ApiOperation("新增/更新教育经历")
    public R<FdEduExperienceDTO> updateEduExp(@RequestBody FdEduExperienceDTO body){
        return R.ok(fdUserService.updateEduExp(body));
    }

    // 删除教育经历 byid
    @DeleteMapping("/edu-exp/remove/{id}")
    @ApiOperation("删除教育经历")
    public R<Boolean> deleteEduExp(@PathVariable("id") Long id){
        return R.ok(fdUserService.deleteEduExp(id));
    }

    // 更新工作经历
    @PostMapping("/work-exp")
    @ApiOperation("新增/更新工作经历")
    public R<FdWorkExperienceDTO> updateWorkExp(@RequestBody FdWorkExperienceDTO body){
        return R.ok(fdUserService.updateWorkExp(body));
    }

    // 删除工作经历 byid
    @DeleteMapping("/work-exp/remove/{id}")
    @ApiOperation("删除工作经历")
    public R<Boolean> deleteWorkExp(@PathVariable("id") Long id){
        return R.ok(fdUserService.deleteWorkExp(id));
    }

    // 更新证书
    @PostMapping("/certificate")
    @ApiOperation("更新/新增证书")
    public R<FdUserCertDTO> updateCertificate(@RequestBody FdUserCertDTO body){
        return R.ok(fdUserService.updateCertificate(body));
    }

    // 删除证书
    @DeleteMapping("/certificate/remove/{id}")
    @ApiOperation("删除证书")
    public R<Boolean> deleteCertificate(@PathVariable("id") Long id){
        return R.ok(fdUserService.deleteCertificate(id));
    }

    // 更新/新增技能
    @PostMapping("/skill")
    @ApiOperation("更新/新增技能")
    public R<FdUserSkillDTO> updateSkill(@RequestBody FdUserSkillDTO body){
        return R.ok(fdUserService.updateSkill(body));
    }


    // 删除证书
    @DeleteMapping("/skill/remove/{id}")
    @ApiOperation("删除证书")
    public R<Boolean> deleteSkill(@PathVariable("id") Long id){
        return R.ok(fdUserService.deleteSkill(id));
    }







}
